<script type="text/javascript" >
    jQuery(document).ready(function() {
        jQuery(".galleryVideo a[rel^='prettyPhoto']").prettyPhoto({
            theme:'facebook',
            keyboard_shortcuts: false
        });
        stYoutubeToolbox.sortColumn();
        stYoutubeToolbox.shortAction();
        stYoutubeToolbox.pagingCallbackFunction = function(data){
            data['filter'] = jQuery('#stFilter').val();
            data['userFilter'] = jQuery('#stUserFilter').val();
        };

        stYoutubeToolbox.sortCallbackFunction = function(data){
            data['filter'] = jQuery('#stFilter').val();
            data['userFilter'] = jQuery('#stUserFilter').val();
        }
    });
</script>
<div class="w100p bgl">
    <div class="w100p bgr">
        <div class="inner_container">
            <div class="filter">
                <label><?php _e('Select account', $config['plugin_name']) ?>:</label>
                <select id="stUserFilter" onchange="stYoutubeToolboxCustom.filter1(this, '<?php echo $current_action?>')">
                    <option <?php echo $userFilter == 0 ? 'selected' : '' ?> value="0">All account</option>

                    <?php                    
                    foreach ($users as $user) {
                        if ($userFilter == $user->id) {
                            $select = 'selected';
                        } else {
                            $select = '';
                        }
                    ?>
                        <option <?php echo $select ?> value="<?php echo $user->id ?>"><?php echo $user->user_name ?></option>
                    <?php
                    }
                    ?>
                </select>
                <label><?php _e('Filter', $config['plugin_name']) ?>:</label>
                <select id="stFilter" onchange="stYoutubeToolboxCustom.filter(this, '<?php echo $current_action?>')">
                    <option <?php echo $filter == 'all' ? 'selected' : '' ?> value="all">All</option>
                    <option <?php echo $filter == 'favorite' ? 'selected' : '' ?> value="favorite">Favorite</option>
                    <option <?php echo $filter == 'uploaded' ? 'selected' : '' ?> value="uploaded">Uploaded</option>
                    <?php
                    /*
                    foreach ($playlists as $value) {
                        if ($filter == $value->playlist_id) {
                            $select = 'selected';
                        } else {
                            $select = '';
                        }
                    ?>
                        <option <?php echo $select ?> value="<?php echo $value->playlist_id ?>"><?php echo $value->name ?></option>
                    <?php
                    }
                     *
                     */
                    ?>
                </select>
            </div>
            <br /><br />
            <table class="widefat galleryVideo" cellspacing="0">
                <thead>
                    <tr>
                        <?php print_column_headers('stYoutubeToolbox_st_youtubevideo'); ?>
                    </tr>
                </thead>
                <tbody>
                    <?php
                        if (count($results) > 0) {
                            $tr_class = "";
                            foreach ($results as $result) {
                                if( empty($tr_class) || $tr_class == "class='bg_gray2'"){
                                    $tr_class = "class='bg_gray1'";
                                }else{
                                    $tr_class = "class='bg_gray2'";
                                }
                                if ($result->can_delete == 0) {
                                    $delete = 'remove_favorite';
                                    $delete_text = 'Remove Favorite';
                                } else {
                                    $delete = 'delete';
                                    $delete_text = 'Trash';
                                }
                                $favorite = 'No';
                                $video_type = 'Uploaded';
                                if ($result->favorite == 1) {
                                    $favorite = 'Yes';
                                    $video_type = 'Favorite';
                                }
                               echo "<tr id='$result->id' $tr_class>"
                                //. "<td>" . $result->id . "</td>"
                                . "<td ><div class='pos_rel'>" . stYoutubeToolboxFunctions::limitWords($result->title, 5)
                                . "<div class=\"row-actions short_action\">"
                                . "<span action='youtubeEdit' short_action='' id='$result->id'>Edit | </span>"
                                . "<span action='' short_action='' id='$result->id'><a href=\"http://www.youtube.com/watch?v={$result->video_id}\" rel=\"prettyPhoto\" title=\"\">Play video </a>| </span>"
                                . "<span action='youtubeDetail' short_action='show' id='$result->id' function=\"jQuery.prettyPhoto.loadPage('youtubeDetail', data_post)\">Show | </span>";
                                echo "<span class='trash' short_action='{$delete}' id='$result->id' confirm='Are you sure you want to {$delete_text} this video?'>{$delete_text} </span>"
                                . "</div></div>"
                                . "</td>"
                                . "<td><img height='70' src='" . $result->thumbnail_url . "' alt='' /></td>"
                                //. "<td>" . stYoutubeToolboxFunctions::limitWords($result->title, 5) . "</td>"
                                . "<td>" . stYoutubeToolboxFunctions::limitWords($result->description, 15) . "</td>"
                                . "<td>" . $result->category . "</td>"
                                //. "<td>" . stYoutubeToolboxFunctions::limitWords(str_replace('|*|', ', ', $result->tag), 5) . "</td>"
                                //. "<td>" . $result->duration . "</td>"
                                . "<td>" . $result->view_count . "</td>"
                                . "<td>" . $video_type . "</td>"
                                . "<td>";
                                  if($permission == 1 && $option_facebook['session_key'] != '')
                                      echo "<img src='".str_replace('Youtube','Publish',$config['imagesUrl'])."facebook.gif' style='cursor:pointer;' onclick='jQuery.prettyPhoto.loadPage(\"publish_popup&url=".$result->video_id."&pic=".$result->thumbnail_url."&title=".addslashes($result->title)."&type=youtube\", null,location.href.split(\"?\")[0]+\"?page=stPublishToolbox\")' />";
                                  if($permission_twitter == 1 && $option_twitter['user_token'] != '')
                                      echo "&nbsp;<img src='".str_replace('Youtube','Publish',$config['imagesUrl'])."twitter.png' style='cursor:pointer;' onclick='jQuery.prettyPhoto.loadPage(\"publish_popup&url=".$result->video_id."&pic=".$result->thumbnail_url."&title=".addslashes($result->title)."&type=youtube\", null,location.href.split(\"?\")[0]+\"?page=stTwitterToolbox\")' />";
                                //. "<td>" . $favorite . "</td>"
                                //. "<td>" . str_replace('|*|', '<br>', $result->rating) . "</td>"
                                //. "<td>" . $result->cdate . "</td>"
//                                . "<td>"
//                                . "<div class=\"short_action\">"
//                                . "<span action='stplugin_edit' short_action='' id='$result->id' ><img src=\"{$config['imagesUrl']}edit_icon.png\" alt=\"\" /></span>"
//                                //. "<span><img src=\"{$config['imagesUrl']}unapprove_icon.png\" alt=\"\" /></span>"
//                                . "<span class='trash' short_action='delete' id='$result->id' confirm='<strong>Warning!</strong>Are you sure you want to delete this stplugin?' ><img src=\"{$config['imagesUrl']}bin_icon.png\" alt=\"\" /></span>"
//                                . "</div>"
//                                . "</td>"
                                echo "</tr>"
                                ;
                            }
                        }
                    ?>
                    </tbody>
                </table>
                <div class="page_d">
                <?php echo $pagination ?>
                <div class="cl"></div>
            </div>

        </div>
    </div>
</div>